# 作者：石吴震
# 2024年12月30日10时47分47秒
# 474160957@qq.com


class Gun:
    def __init__(self, model):
        self.model = model
        self.bullets_num = 0

    def add_bullets(self, num):
        self.bullets_num += num

    def shoot(self):
        if self.bullets_num > 0:
            self.bullets_num -= 1
            print( f'{self.model} 还剩 [{self.bullets_num}] 颗子弹')
        else:
            print("No bullets")


class Soldier:
    def __init__(self, name, gun=None):
        self.name = name
        self.gun = gun

    def fire(self):
        if self.gun==None:
            print(f'他准备空手接子弹')
        else:
            return self.gun.shoot()

if __name__ == '__main__':
    ak47 = Gun("AK47")
    # ak47.add_bullets(50)
    # ak47.shoot()
    xusanduo = Soldier("许三多")
    xusanduo.fire()
    xusanduo.gun = ak47
    xusanduo.fire()


